package com.dragon.repository.mapper;

import com.baomidou.mybatisplus.core.InjectorResolver;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dragon.repository.entity.OperationRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * “项目操作记录” Mapper 接口
 * </p>
 *
 * @author sy
 * @since 2023-06-30
 */
@Mapper
public interface OperationRecordMapper extends BaseMapper<OperationRecord> {

    @Select("<script>" +
            "select m.id,m.project_id,m.action_type,m.operation_type,m.operation_time,m.admin_id,m.remark,m.username,concat(m.actionName,'了',n.name) comment from " +
            "(select a.*, b.username, c.name actionName from dragon_operation_record a " +
            "left join dragon_admin b on a.admin_id = b.id " +
            "left join dragon_dictsort_detail c on a.action_type = c.value and c.code_type = 'actionCode') m,dragon_dictsort_detail n " +
            "where m.operation_type = n.value and n.code_type = 'streamCode' " +
            "<if test='projectIds.size!=0'>" +
            "AND m.project_id in" +
            "<foreach collection = 'projectIds' item = 'item' open = '(' close = ')' separator = ','>" +
            "#{item}" +
            "</foreach>" +
            "</if>"+
            " order by m.operation_time desc</script>")
    Page<OperationRecord> selectPageList(Page<OperationRecord> page, List<Integer> projectIds);

}
